let ajax = getApp().globalData.ajax;
let boyIcon = 'http://image.tanwancat.com/bd1c02e340602de3e03ac39f4230c325_20_20.jpeg';
let girlIcon = 'http://image.tanwancat.com/52390029eaa13ee3d090edea832b15d4_20_20.jpeg'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderInfo:{},
    chatIcon:'http://weiyou-image-online.oss-cn-zhangjiakou.aliyuncs.com/image/%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF.png?Expires=1843271327&OSSAccessKeyId=LTAILPpS7R3UXAnz&Signature=BWOEQQocJf1LDXVzSZ%2BjxAn6vBY%3D',
    anchorsInfo:{
      name:'艾斯特罗',
      headerImg:'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=547109617,1156722171&fm=27&gp=0.jpg',
      gender:0,
      age:20,
    },
    genderSrc:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id=options.id;
    
    let json={
      token: wx.getStorageSync('Cookie'),
      order_id:id,
    }
    ajax('order/detail', json).then(res=>{
      let orderInfo=res.data.orders;
      orderInfo.createTime = orderInfo.create_time.toDateString();
      if (orderInfo.seller.gender === '女') {

        this.setData({
          genderSrc: girlIcon
        })
      } else {
        this.setData({
          genderSrc: boyIcon
        })
      }
      switch (orderInfo.status) {
        case 'INIT':
          orderInfo.statusRes = '未支付';
          break;
        case 'BUYER_START':
          orderInfo.statusRes = '未支付';
          break;
        case 'PAYED':
          orderInfo.statusRes = '已支付';
          break;
        case 'CANCELED':
          orderInfo.statusRes = '已取消';
          break;
        case 'READY':
          orderInfo.statusRes = '已确认';
          break;
        case 'ONGOING':
          orderInfo.statusRes = '进行中';
          break;
        case 'FINISH_AUTO':
          orderInfo.statusRes = '已完成';
          break;
        case 'FINISH':
          orderInfo.statusRes = '已完成';
          break;
        case 'PAYED':
          orderInfo.statusRes = '已支付';
          break;
        case 'PAYED PAY':
          orderInfo.statusRes = '已支付';
          break;
        case 'SELLER_START':
          orderInfo.statusRes = '已接单';
          break;

      }
      this.setData({ orderInfo});
    })

  },

  chatBtnHandler(e) {
    let account = e.currentTarget.dataset.account;
    wx.navigateTo({
      url: '../../partials/chating/chating?chatTo=' + account,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})